using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


//简单工厂模式

/// <summary>
/// 运算工厂类
/// </summary>
public class OperationFactory 
{
    /// <summary>
    /// 根据运算类型，创建运算类
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    public static Operation CreateOperation(OperateType type)
    {
        Operation oper = null;

        switch (type)
        {
            case OperateType.Add:
                oper = new OperationAdd();
                break;
            case OperateType.Sub:
                oper = new OperationSub();
                break;
            case OperateType.Mul:
                oper = new OperationMul();
                break;
            case OperateType.Div:
                oper = new OperationDiv();
                break;
        }

        return oper;
    }
}

/// <summary>
/// 运算类型
/// </summary>
public enum OperateType
{
    /// <summary>
    /// 加
    /// </summary>
    Add = 0,

    /// <summary>
    /// 减
    /// </summary>
    Sub = 1,

    /// <summary>
    /// 乘
    /// </summary>
    Mul = 2,

    /// <summary>
    /// 除
    /// </summary>
    Div = 3,
}

